package com.springboot.rabbitmq.route;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @Author: lzx
 * @Data: 2021/04/29/14:31
 * @Description：
 */
@Component
public class TopicRouteCustomer {
    //匹配1个词
    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue,
                    exchange = @Exchange(type="topic",name="topics"),
                    key = {"user.save","user.*"}
            )
    })
    public void receive1(String message) {
        System.out.println("message1：" + message);
    }
    //匹配多个词，用 "."分隔
    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue,
                    exchange = @Exchange(type="topic",name="topics"),
                    key = {"order.#","product.#","user.#"}
            )
    })
    public void receive2(String message) {
        System.out.println("message2：" + message);
    }
}
